next up previous contents index
Next: Constructors and destructors Up: Objects Previous: Declaration

Fields

Object Fields are like record fields. They are accessed in the same way as you would access a record field : by using a qualified identifier. Given the following declaration:
listing1973
then the following would be a valid assignment:
listing1975

Inside methods, fields can be accessed using the short identifier:
listing1977
Or, one can use the self identifier. The self identifier refers to the current instance of the object:
listing1981

You cannot access fields that are in a private section of an object from outside the objects' methods. If you do, the compiler will complain about an unknown identifier.

It is also possible to use the with statement with an object instance:
listing1984
In this example, between the begin and end, it is as if AnObject was prepended to the Afield and Amethod identifiers. More about this in section (gif)


next up previous contents index
Next: Constructors and destructors Up: Objects Previous: Declaration

Michael Van Canneyt
Fri Sep 25 09:15:40 MEST 1998